﻿package mortal.game.view.guildNew.manor
{
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import com.mui.display.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.guild.otherpanel.*;
    import mortal.mvc.core.*;

    public class GuildNewManorCell extends GCellRenderer
    {
        protected var _nameDes:GTextFiled;
        protected var _mor:GTextFiled;
        protected var _line:ScaleBitmap;
        protected var _level:GTextFiled;
        protected var _notMature:GTextFiled;
        protected var _mature:GTextFiled;
        protected var _enter:GButton;
        protected var _friuts:GBitmap;
        protected var _txtRank:GTextFiled;
        protected var _bmpRank:GBitmap;
        private var _isMyGuildEffect:ScaleBitmap;
        private var _saveData:SMiniGuildInfo;

        public function GuildNewManorCell()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._nameDes = UIFactory.gTextField("", 16, 6, 110, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).center().setUnderline(true));
            this._mor = UIFactory.gTextField("", 160, 7, 106, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).center());
            this._line = UIFactory.bg(0, 31, 745, 1, this, ImagesConst.SplitLine);
            this._level = UIFactory.gTextField("10", 280, 8, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).center());
            this._notMature = UIFactory.gTextField("" + Language.getString(71480), 439, 9, 100, 20, this, GlobalStyle.textFormatHong);
            this._mature = UIFactory.gTextField("" + Language.getString(71481), 439, 10, 120, 20, this, GlobalStyle.textFormatHuang2);
            this._enter = UIFactory.gButton("" + Language.getString(71482), 623, 4, 70, 25, this);
            this._friuts = UIFactory.gBitmap(ImagesConst.guidlRankFruite2, 411, 9, this);
            this._txtRank = UIFactory.gTextField("1", -2, 6, 30, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).center());
            this._bmpRank = UIFactory.gBitmap(ImagesConst.guildNewRank1_icon, 3, 5, this);
            this._enter.configEventListener(MouseEvent.CLICK, this.onEnterOtherManor);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._nameDes = null;
            this._mor = null;
            this._line = null;
            this._level = null;
            this._notMature = null;
            this._mature = null;
            this._enter = null;
            this._friuts = null;
            this._txtRank = null;
            this._bmpRank = null;
            this._isMyGuildEffect = null;
            super.disposeImpl(param1);
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_2:* = param1 as SMiniGuildInfo;
            this._saveData = _loc_2;
            if (_loc_2.guildId == Cache.instance.guild.selfGuildInfo.guildID)
            {
                if (this._isMyGuildEffect == null)
                {
                    this._isMyGuildEffect = UIFactory.bg(0, 0, 725, this.height, this, ImagesConst.selectedBg);
                }
                else
                {
                    this._isMyGuildEffect.visible = true;
                }
            }
            else if (this._isMyGuildEffect)
            {
                this._isMyGuildEffect.visible = false;
            }
            if (_loc_2.rank == 1)
            {
                this._bmpRank.bitmapData = GlobalClass.getBitmapData(ImagesConst.guildNewRank1_icon);
            }
            else if (_loc_2.rank == 2)
            {
                this._bmpRank.bitmapData = GlobalClass.getBitmapData(ImagesConst.guildNewRank2_icon);
            }
            else if (_loc_2.rank == 3)
            {
                this._bmpRank.bitmapData = GlobalClass.getBitmapData(ImagesConst.guildNewRank3_icon);
            }
            else
            {
                this._bmpRank.bitmapData = null;
            }
            this._txtRank.text = _loc_2.rank.toString();
            this._nameDes.htmlText = "<a href=\'event:guildlink\' target = \'\'><font color=\'#ffffff\'><u>" + _loc_2.guildName + "</u></font></a>";
            this._nameDes.configEventListener(TextEvent.LINK, this.onGuildLink);
            this._mor.text = _loc_2.leaderName;
            this._level.text = _loc_2.level.toString();
            this._enter.visible = true;
            var _loc_3:* = ClockManager.instance.nowDate;
            var _loc_4:* = this._saveData.nextPickUpDt;
            if (_loc_3.time >= _loc_4.time && Cache.instance.guild.selfGuildInfo.baseInfo.level >= 3)
            {
                this._friuts.visible = true;
                this._mature.visible = true;
                this._notMature.visible = false;
            }
            else
            {
                this._friuts.visible = false;
                this._mature.visible = false;
                this._notMature.visible = true;
            }
            return;
        }// end function

        private function onEnterOtherManor(event:MouseEvent) : void
        {
            if (Cache.instance.guild.selfGuildInfo.selfInfo.level < 3)
            {
                MsgManager.showRollTipsMsg("" + Language.getStringByParam(71483, 3));
                return;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.Guild_enterManor, this._saveData.guildId));
            return;
        }// end function

        protected function onGuildLink(event:TextEvent) : void
        {
            GuildIntroducePanel.instance.setGuildInfo(this._saveData);
            GuildIntroducePanel.instance.show();
            return;
        }// end function

    }
}
